View Javadoc

1   /*
2    * LocalId.java
3    *
4    * Created on January 5, 2005, 5:32 PM
5    */
6   
7   package org.opensciencegrid.authz.common;
8   
9   /*** Represents a local user identity, as estabilished by the GRID Identity
10   * Mapping Service.
11   *
12   * @author Gabriele Carcassi and Markus Lorch
13   */
14  public class LocalId {
15  
16      private String userName;
17      private String groupName;
18      private String[] supplementalGroupNames;
19      private String rootPath;
20      private String relHomePath;
21  
22      public LocalId() {
23      }
24  
25      public LocalId  (String userName, String groupName, String[] supplementalGroupNames,
26                                String rootPath, String relHomePath) {
27  
28        this.userName = userName;
29        this.groupName = groupName;
30        if(supplementalGroupNames != null) {
31          this.supplementalGroupNames = new String[supplementalGroupNames.length];
32          for(int i=0; i < supplementalGroupNames.length; i++)
33             this.supplementalGroupNames[i] = supplementalGroupNames[i];
34        }
35        this.rootPath = rootPath;
36        this.relHomePath = relHomePath;
37  
38      }
39  
40  
41  
42  
43      /***
44       * The username for the local identity.
45       * @return a UNIX username (i.e. "carcassi").
46       */
47      public String getUserName() {
48  
49          return this.userName;
50      }
51  
52      /***
53       * Changes the  username for the local identity.
54       * @param username a UNIX username (i.e. "carcassi").
55       */
56      public void setUserName(String userName) {
57  
58          this.userName = userName;
59      }
60  
61      /***
62       * The primary group for the local identity.
63       * @return a UNIX group name (i.e. "atlas").
64       */
65       public String getGroupName() {
66          return this.groupName;
67      }
68  
69  
70      /***
71       * Changes the primary group for the local identity.
72       * @param group a UNIX group name (i.e. "atlas").
73       */
74  
75       public void setGroupName(String g) {
76         this.groupName = g;
77       }
78  
79  
80      /***
81       * Getter for property supplementalGroups.
82       * @return Value of property supplementalGroups.
83       */
84      public String[] getSupplementalGroupNames() {
85  
86          return this.supplementalGroupNames;
87      }
88  
89      /***
90       * Setter for property supplementalGroups.
91       * @param supplementalGroups New value of property supplementalGroups.
92       */
93      public void setSupplementalGroupNames(String[] sg) {
94          this.supplementalGroupNames = new String[sg.length];
95          for(int i=0; i < sg.length; i++)
96             this.supplementalGroupNames[i] = sg[i];
97      }    
98  
99  
100     /***
101      * Getter for property rootPath.
102      * @return Value of property rootPath.
103      */
104     public String getRootPath() {
105 
106         return this.rootPath;
107     }
108 
109     /***
110      * Setter for property rootPath.
111      * @param rootPath New value of property rootPath.
112      */
113     public void setRootPath(String rootPath) {
114 
115         this.rootPath = rootPath;
116     }
117 
118     /***
119      * Getter for property relHomePath.
120      * @return Value of property relHomePath.
121      */
122     public String getRelativeHomePath() {
123 
124         return this.relHomePath;
125     }
126 
127     /***
128      * Setter for property relHomePath.
129      * @param relHomePath New value of property relHomePath.
130      */
131     public void setRelativeHomePath(String relHomePath) {
132 
133         this.relHomePath = relHomePath;
134     }
135 
136     public String toString() {
137         StringBuffer sb = new StringBuffer("LocalId[");
138         if (userName != null) {
139             sb.append("userName: ");
140             sb.append(userName);
141         }
142         if (groupName != null) {
143             if (sb.length() != 8) sb.append(" - ");
144             sb.append("groupName: ");
145             sb.append(groupName);
146         }
147         if (rootPath != null) {
148             if (sb.length() != 8) sb.append(" - ");
149             sb.append("rootPath: ");
150             sb.append(rootPath);
151         }
152         if (relHomePath != null) {
153             if (sb.length() != 8) sb.append(" - ");
154             sb.append("relHomePath: ");
155             sb.append(relHomePath);
156         }
157         sb.append(']');
158         return sb.toString();
159     }
160     
161     
162 }